import 'package:flutter/material.dart';
import '../../widgets/CircleColorPicker.dart';
import 'dart:ui';
import '../../widgets/ColorPreview.dart';

class CircleColorPickerDemoPage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {

    return new CircleColorPickerDemoPageState();
  }

}

class CircleColorPickerDemoPageState extends State<CircleColorPickerDemoPage>{

  Color mColor = Colors.lightGreenAccent;

  @override
  Widget build(BuildContext context) {

    return new Scaffold(

      appBar: new AppBar(
        title: new Text('圆形取色器'),
        backgroundColor: Colors.blue,
      ),

      body: new SingleChildScrollView(

        child: new Column(

          children: <Widget>[

            new Padding(
              padding: new EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0),
              child: new Row(
                children: <Widget>[

                  new Center(

                      child: new ColorPreview(previewColor: mColor),

                  ),
                ],
              ),
            ),

            new CircleColorPicker(
              width: window.physicalSize.width/window.devicePixelRatio*0.8,
              height: window.physicalSize.width/window.devicePixelRatio*0.8,
              onChangeStart: (color){

                setState(() {

                  mColor = color;

                });

              },
              onChange: (color){

                print(color.toString());

                setState(() {

                  mColor = color;

                });


              },
              onChangeEnd: (){


              },
            ),

          ],

        ),

      ),

    );
  }

}



